home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / MachineExceptions.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  6.5 KB  |  247 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        MachineExceptions.h
  3.  
  4.      Contains:    Processor Exception Handling Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1993-1999 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __MACHINEEXCEPTIONS__
  18. #define __MACHINEEXCEPTIONS__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=power
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47. /* Some basic declarations used throughout the kernel */
  48. typedef struct OpaqueAreaID*             AreaID;
  49. #if TARGET_OS_MAC
  50. /* Machine Dependent types for PowerPC: */
  51.  
  52. struct MachineInformationPowerPC {
  53.     UnsignedWide                     CTR;
  54.     UnsignedWide                     LR;
  55.     UnsignedWide                     PC;
  56.     unsigned long                     CR;
  57.     unsigned long                     XER;
  58.     unsigned long                     MSR;
  59.     unsigned long                     MQ;
  60.     unsigned long                     ExceptKind;
  61.     unsigned long                     DSISR;
  62.     UnsignedWide                     DAR;
  63.     UnsignedWide                     Reserved;
  64. };
  65. typedef struct MachineInformationPowerPC MachineInformationPowerPC;
  66.  
  67. struct RegisterInformationPowerPC {
  68.     UnsignedWide                     R0;
  69.     UnsignedWide                     R1;
  70.     UnsignedWide                     R2;
  71.     UnsignedWide                     R3;
  72.     UnsignedWide                     R4;
  73.     UnsignedWide                     R5;
  74.     UnsignedWide                     R6;
  75.     UnsignedWide                     R7;
  76.     UnsignedWide                     R8;
  77.     UnsignedWide                     R9;
  78.     UnsignedWide                     R10;
  79.     UnsignedWide                     R11;
  80.     UnsignedWide                     R12;
  81.     UnsignedWide                     R13;
  82.     UnsignedWide                     R14;
  83.     UnsignedWide                     R15;
  84.     UnsignedWide                     R16;
  85.     UnsignedWide                     R17;
  86.     UnsignedWide                     R18;
  87.     UnsignedWide                     R19;
  88.     UnsignedWide                     R20;
  89.     UnsignedWide                     R21;
  90.     UnsignedWide                     R22;
  91.     UnsignedWide                     R23;
  92.     UnsignedWide                     R24;
  93.     UnsignedWide                     R25;
  94.     UnsignedWide                     R26;
  95.     UnsignedWide                     R27;
  96.     UnsignedWide                     R28;
  97.     UnsignedWide                     R29;
  98.     UnsignedWide                     R30;
  99.     UnsignedWide                     R31;
  100. };
  101. typedef struct RegisterInformationPowerPC RegisterInformationPowerPC;
  102.  
  103. struct FPUInformationPowerPC {
  104.     UnsignedWide                     Registers[32];
  105.     unsigned long                     FPSCR;
  106.     unsigned long                     Reserved;
  107. };
  108. typedef struct FPUInformationPowerPC    FPUInformationPowerPC;
  109.  
  110. union Vector128 {
  111. #ifdef __VEC__
  112.     vector unsigned long            v;
  113. #endif
  114.     unsigned long                     l[4];
  115.     unsigned short                     s[8];
  116.     unsigned char                     c[16];
  117. };
  118. typedef union Vector128                    Vector128;
  119.  
  120. struct VectorInformationPowerPC {
  121.     Vector128                         Registers[32];
  122.     Vector128                         VSCR;
  123.     UInt32                             VRsave;
  124. };
  125. typedef struct VectorInformationPowerPC    VectorInformationPowerPC;
  126. /* Exception related declarations */
  127. enum {
  128.     kWriteReference                = 0,
  129.     kReadReference                = 1,
  130.     kFetchReference                = 2,
  131.     writeReference                = kWriteReference,                /* Obsolete name*/
  132.     readReference                = kReadReference,                /* Obsolete name*/
  133.     fetchReference                = kFetchReference                /* Obsolete name*/
  134. };
  135.  
  136.  
  137. typedef unsigned long                     MemoryReferenceKind;
  138.  
  139. struct MemoryExceptionInformation {
  140.     AreaID                             theArea;
  141.     LogicalAddress                     theAddress;
  142.     OSStatus                         theError;
  143.     MemoryReferenceKind             theReference;
  144. };
  145. typedef struct MemoryExceptionInformation MemoryExceptionInformation;
  146. enum {
  147.     kUnknownException            = 0,
  148.     kIllegalInstructionException = 1,
  149.     kTrapException                = 2,
  150.     kAccessException            = 3,
  151.     kUnmappedMemoryException    = 4,
  152.     kExcludedMemoryException    = 5,
  153.     kReadOnlyMemoryException    = 6,
  154.     kUnresolvablePageFaultException = 7,
  155.     kPrivilegeViolationException = 8,
  156.     kTraceException                = 9,
  157.     kInstructionBreakpointException = 10,
  158.     kDataBreakpointException    = 11,
  159.     kIntegerException            = 12,
  160.     kFloatingPointException        = 13,
  161.     kStackOverflowException        = 14,
  162.     kTaskTerminationException    = 15,
  163.     kTaskCreationException        = 16
  164. };
  165.  
  166. #if OLDROUTINENAMES
  167. enum {
  168.     unknownException            = kUnknownException,            /* Obsolete name*/
  169.     illegalInstructionException    = kIllegalInstructionException,    /* Obsolete name*/
  170.     trapException                = kTrapException,                /* Obsolete name*/
  171.     accessException                = kAccessException,                /* Obsolete name*/
  172.     unmappedMemoryException        = kUnmappedMemoryException,        /* Obsolete name*/
  173.     excludedMemoryException        = kExcludedMemoryException,        /* Obsolete name*/
  174.     readOnlyMemoryException        = kReadOnlyMemoryException,        /* Obsolete name*/
  175.     unresolvablePageFaultException = kUnresolvablePageFaultException, /* Obsolete name*/
  176.     privilegeViolationException    = kPrivilegeViolationException,    /* Obsolete name*/
  177.     traceException                = kTraceException,                /* Obsolete name*/
  178.     instructionBreakpointException = kInstructionBreakpointException, /* Obsolete name*/
  179.     dataBreakpointException        = kDataBreakpointException,        /* Obsolete name*/
  180.     integerException            = kIntegerException,            /* Obsolete name*/
  181.     floatingPointException        = kFloatingPointException,        /* Obsolete name*/
  182.     stackOverflowException        = kStackOverflowException,        /* Obsolete name*/
  183.     terminationException        = kTaskTerminationException,    /* Obsolete name*/
  184.     kTerminationException        = kTaskTerminationException        /* Obsolete name*/
  185. };
  186.  
  187. #endif  /* OLDROUTINENAMES */
  188.  
  189.  
  190. typedef unsigned long                     ExceptionKind;
  191.  
  192. union ExceptionInfo {
  193.     MemoryExceptionInformation *    memoryInfo;
  194. };
  195. typedef union ExceptionInfo                ExceptionInfo;
  196.  
  197. struct ExceptionInformationPowerPC {
  198.     ExceptionKind                     theKind;
  199.     MachineInformationPowerPC *        machineState;
  200.     RegisterInformationPowerPC *    registerImage;
  201.     FPUInformationPowerPC *            FPUImage;
  202.     ExceptionInfo                     info;
  203.     VectorInformationPowerPC *        vectorImage;
  204. };
  205. typedef struct ExceptionInformationPowerPC ExceptionInformationPowerPC;
  206. #if TARGET_CPU_PPC || TARGET_CPU_68K
  207.  
  208. typedef ExceptionInformationPowerPC     ExceptionInformation;
  209. typedef MachineInformationPowerPC         MachineInformation;
  210. typedef RegisterInformationPowerPC         RegisterInformation;
  211. typedef FPUInformationPowerPC             FPUInformation;
  212. typedef VectorInformationPowerPC         VectorInformation;
  213. #endif  /* TARGET_CPU_PPC || TARGET_CPU_68K */
  214.  
  215. /* 
  216.     Note:    An ExceptionHandler is NOT a UniversalProcPtr.
  217.             It must be a PowerPC function pointer with NO routine descriptor. 
  218. */
  219. typedef CALLBACK_API_C( OSStatus , ExceptionHandler )(ExceptionInformation *theException);
  220. /* Routine for installing per-process exception handlers */
  221. EXTERN_API( ExceptionHandler ) InstallExceptionHandler(ExceptionHandler theHandler);
  222.  
  223. #endif  /* TARGET_OS_MAC */
  224.  
  225.  
  226.  
  227. #if PRAGMA_STRUCT_ALIGN
  228.     #pragma options align=reset
  229. #elif PRAGMA_STRUCT_PACKPUSH
  230.     #pragma pack(pop)
  231. #elif PRAGMA_STRUCT_PACK
  232.     #pragma pack()
  233. #endif
  234.  
  235. #ifdef PRAGMA_IMPORT_OFF
  236. #pragma import off
  237. #elif PRAGMA_IMPORT
  238. #pragma import reset
  239. #endif
  240.  
  241. #ifdef __cplusplus
  242. }
  243. #endif
  244.  
  245. #endif /* __MACHINEEXCEPTIONS__ */
  246.  
  247.